#pragma once

#include "UMLStereotypePropertyValueLabel.h"

#include "../uml/Element.h"
#include "../uml/Property.h"

namespace uml {

UMLStereotypePropertyValueLabel::UMLStereotypePropertyValueLabel(const QString& umlType)
    : UMLLabel(umlType) {}

void UMLStereotypePropertyValueLabel::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLLabel::fromJson(json, errorList);
    modelElement_ = JsonSerializable::create<Property>(json.value("modelElement"), errorList);

    stereotypedElement_ = JsonSerializable::create<Element>(json.value("stereotypedElement"), errorList);

}

void UMLStereotypePropertyValueLabel::toJson(QJsonObject& json) {
    UMLLabel::toJson(json);
    if (modelElement_) {
        QJsonObject modelElement_json;
        modelElement_->toJson(modelElement_json);
        json.insert("modelElement", modelElement_json);
    }
    if (stereotypedElement_) {
        QJsonObject stereotypedElement_json;
        stereotypedElement_->toJson(stereotypedElement_json);
        json.insert("stereotypedElement", stereotypedElement_json);
    }
}

/// <summary>
/// modelElement getter
/// A Property of a Stereotype applied to the stereotypedElement.
/// </summary>
shared_ptr<Property> UMLStereotypePropertyValueLabel::modelElement() const {
    return modelElement_;
}

/// <summary>
/// modelElement setter
/// A Property of a Stereotype applied to the stereotypedElement.
/// </summary>
void UMLStereotypePropertyValueLabel::setModelElement(shared_ptr<Property> value) {
    modelElement_ = value;
}

/// <summary>
/// stereotypedElement getter
/// Element to which a Stereotype having the modelElement (Property) is applied.
/// </summary>
shared_ptr<Element> UMLStereotypePropertyValueLabel::stereotypedElement() const {
    return stereotypedElement_;
}

/// <summary>
/// stereotypedElement setter
/// Element to which a Stereotype having the modelElement (Property) is applied.
/// </summary>
void UMLStereotypePropertyValueLabel::setStereotypedElement(shared_ptr<Element> value) {
    stereotypedElement_ = value;
}

} // namespace uml
